package pers.cz.service.impl;

import pers.cz.business.FileUploadBusiness;
import pers.cz.commons.upload.FileUploadLog;
import pers.cz.pub.BeanHelper;
import pers.cz.service.FileUploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * @program: PostGirl-panent
 * @description: FileUploadServiceImpl
 * @author: Cheng Zhi
 * @create: 2021-03-10 10:00
 **/
@Service
public class FileUploadServiceImpl implements FileUploadService {

    @Autowired
    private BeanHelper beanHelper;

    public BeanHelper getBeanHelper() {
        return beanHelper;
    }

    public void setBeanHelper(BeanHelper beanHelper) {
        this.beanHelper = beanHelper;
    }

    @Override
    public Integer upload(MultipartFile file, Integer userId) throws IOException {

        int count = 0;
        FileUploadBusiness business = new FileUploadBusiness();
        business.setMapper(beanHelper);
        count = business.upload(file, userId);

        return count;
    }

    @Override
    public Long insertFileUploadBusi(String fileName, Integer userId, String remarks) {
        Long count = 0L;
        count = FileUploadLog.insertFileUploadBusi(fileName, userId, remarks);
        return count;
    }
}
